<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="referrer" content="always">
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta name="referrer" content="always">
<meta content="telephone=no, address=no" name="format-detection">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>大转盘</title>

<script type='text/javascript'>

  var member_id = localStorage.getItem('member_id');
  if(!member_id) location.href="/register";


  var g_rem = 20;
  (function(win){
      var orientationX = false; //是否横屏进来
      if(win.orientation==90||win.orientation==-90){
          orientationX = true;
      }
      var docEl = win.document.documentElement,tid;
      function refreshRem1(){
          g_rem = docEl.getBoundingClientRect().width/16;
          !g_rem && (g_rem = 20);
          docEl.style.fontSize = g_rem + 'px';
      }
      function refreshRem2(){
          g_rem = docEl.getBoundingClientRect().width/16;
          if(!g_rem){
              return refreshRem1();
          }
          var width = docEl.getBoundingClientRect().width;
          var d = win.document.createElement('div');
          d.style.width = '1rem';
          d.style.display = "none";
          docEl.firstElementChild.appendChild(d);
          var defaultFontSize = parseFloat(window.getComputedStyle(d, null).getPropertyValue('width'));
          docEl.firstElementChild.removeChild(d);
          docEl.style.fontSize = (g_rem/defaultFontSize)*100 + '%';
      }
      var refreshRem = /HUAWEI TIT-TL00/i.test(navigator.userAgent) ? refreshRem2 : refreshRem1;
      try{
          win.addEventListener("orientationchange", function() {//触发手机横屏竖屏事件
              if(orientationX){
                  location.reload();
              }
          }, false);
      }catch(e){}
      win.addEventListener('pageshow', function(e) {
          if (e.persisted) {
              clearTimeout(tid);
              tid = setTimeout(refreshRem, 100);
          }
      }, false);
      refreshRem();
  })(window);
</script>

<link href="/static/zp/base.min.css" rel="stylesheet" type="text/css" />
<link href="/static/zp/hlcbt.min.css" rel="stylesheet" type="text/css" />
<link href="/static/zp/weui.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

</head>
<body class="body">
  <!-- loading页面 -->
  <div id="preloadPage" class="bg">
    <div class="spinner">
      <div class="spinner-container container1">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
      <div class="spinner-container container2">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
      <div class="spinner-container container3">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
    </div>

    <div class="info"><span id="loadPercent">0</span>%</div>
    <div id="userPreload" data-src="http://7020498.h40.faiusr.com/4/2Tdi124zdGcmeWfla2ckbDNkFDOkljM.png"></div>
  </div>

  <div class="ajaxLoadBg">
    <div class="ajaxLoadBar "></div>
  </div>
  <div class="home">
    <div id="homeBgBox">
      <img id="homeBg" src="/static/zp/ACgIABACGAAguZ28zwUoiM-W2AUwgAU4wAw.jpg"/>
    </div>
    <div class="showGifBoxer editTarget-showGifBoxer">
      <div class="theShowerGiftBoxer">
        <div class="priceBox"></div>
        <div class="theLightBox">
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
          <div class="editTarget-flashLight theRealFlashLight abs"></div>
          <div class="editTarget-darkLight theRealFlashLight abs"></div>
        </div>
        <div class="startBtnImg editTarget-startBtnImg"></div>
      </div>
      <div class="theBoxerForEdit hide">
        <div class="editTarget-priceD"></div>
      </div>
      <canvas id="outer">您的浏览器不支持canvas，请换一个牛逼一点的浏览器，谢谢</canvas>
    </div>
    <div class='gameInfoBox'>
      <div class="titleImg imgContainer absCenter ">
      </div>
    </div>
  </div>
  <div id="pageMusic" style="position:absolute;top:0;height:0;"></div>

    <div class="resuleBox hide">
      <div id="resule-status-box" style="display:none">

          <div id="resule-status-lotsBox" style="display:none">
              <img id="resule-status-lots" class="editTarget-lotsPot">
              <div id="resule-status-lotsHand" class="editTarget-lotsShakeHand">
                  <div class="shakeHand"></div>
                  <div class="shakeTxt"></div>
                  <div class="waitDrawBtn" style="display:none">点击抽奖</div>
              </div>
          </div>
      </div>
      <div id="resule-gift-box" style="display:none">
        <div id="resule-gift-scrollWrap" class="resule-gift-overflowScrolling" style="padding-top:1.2rem;position:relative;z-index:300;">
          <div class="resule-bgLight"></div>
          <div id="luckContainer" style="position:absolute; width: 100%;z-index:250;">
            <p id="resule-gift-luck" style="text-align:center;" >恭喜你获得了</p>
            <div class="imgContentLimit hide" style="width: 14rem; height: 30rem; position: absolute;"></div>
            <div class="imgContainer" style="position:relative;">
              <img id="resule-gift-sucImg" class="slaveImg">
            </div>
            <div id="resule-gift-foot">
              <p id="resule-gift-rank"> <span class="gifArg awardStyle"></span> </p>
              <p id="resule-gift-goods"> <span class="gifArg awardName"></span> </p>
            </div>
            <div id="resule-gift-buttonMenu">
              <div class="giftBtnBox lookDetail">
                <a class="seeAwardDetail buttonContent">查看奖品详情</a>
              </div>
            </div>
          </div>
        </div>
        <div id="faiImgBox">
          <div class="cannotGetThePriceBox oldGame"></div>
          <img class="abs editTarget-theGetPricePic theUnPriceImg" id="theGetPricePic" />
          <!-- <div class='resule-gift-home menuAgain'>再来一次</div> -->
        </div>

        <div id="resule-gift-buttonMenu-bottom">
          <div class="giftBtnBox lookDetail">
            <a class="seeAwardDetail buttonContent">查看奖品详情</a>
          </div>
        </div>

        <div class='attentionBox'>
        	<!-- <div class='menuBtnBox'>
            <a class='menuName'></a>
          </div> -->
          <div class="holdBox"></div>
        </div>
      </div>
    </div>


<script src="https://cdn.bootcss.com/lodash.js/4.17.5/lodash.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/zp/hdUtil.min.js"></script>
<script type="text/javascript" src="/static/zp/hdgame.min.js"></script>
<script type="text/javascript" src="/static/zp/lufylegend.min.js"></script>

<script type="text/javascript">
    var tryPlay = true, _resRoot = '/static/zp', hg = {};

    (function(hg) {
        var imgPaths = [],
            readyCallBack = [],
            loadCallBack = [];
        hg.assets = {
            complete: false,
            loadComplete: false,
            increment: 0,
            loadingStyle: 1,
            loadTimeout: 120000,
            getPath: function() {
                return imgPaths
            },
            setPath: function(path) {
                imgPaths = path
            },
            add: function(src) {
                var self = this;
                if (self.complete) {
                    return
                }
                if (_.isArray(src)) {
                    for (var i = src.length - 1; i >= 0; i--) {
                        self.add(src[i])
                    }
                } else if (typeof src === 'string') {
                    imgPaths.push(src)
                }
                return this
            },
            onReady: function(callBack) {
                var self = this;
                if (self.complete) {
                    callBack()
                } else {
                    readyCallBack.push(callBack)
                }
                return self
            },
            onload: function(callBack) {
                var self = this;
                if (self.loadComplete) {
                    callBack()
                } else {
                    loadCallBack.push(callBack)
                }
                return self
            },
            loadPage: function() {
                var self = this,
                    percent = 1,
                    numLoaded = 0,
                    $loadPercent = document.getElementById("loadPercent"),
                    loadPallet;
                window.scrollTo(0, 0);
                if (self.loadingStyle === 1) {
                    loadimg(imgPaths)
                } else if (self.loadingStyle === 3) {
                    var logoImg = document.getElementById("preloadImg");
                    var initLogoImg = function(img) {
                        var img = logoImg;
                        var h = img.height;
                        var w = img.width;
                        var bottomPageInfoDeg = -Math.atan(w / h) - Math.PI / 2;
                        var canvas = document.getElementById("preloadCanvas");
                        var ctx = canvas.getContext("2d");
                        var ratio = (window.devicePixelRatio || 1) / (ctx.backingStorePixelRatio || ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
                        var drawImg = function() {
                            ctx.fillStyle = "#fff";
                            ctx.fillRect(0.2 * g_rem * ratio, 0.2 * g_rem * ratio, w * ratio, h * ratio);
                            ctx.drawImage(img, 0.2 * g_rem * ratio, 0.2 * g_rem * ratio, w * ratio, h * ratio)
                        };
                        if (h === w) {
                            if (h > 3.5 * g_rem) {
                                h = w = 3.5 * g_rem
                            }
                            drawImg = function() {
                                ctx.save();
                                ctx.beginPath();
                                ctx.arc(canvas.width / 2, canvas.height / 2, w / 2 * ratio, 0, 2 * Math.PI);
                                ctx.clip();
                                ctx.fillStyle = "#fff";
                                ctx.fill();
                                ctx.drawImage(img, 0.2 * g_rem * ratio, 0.2 * g_rem * ratio, w * ratio, h * ratio);
                                ctx.restore()
                            }
                        } else {
                            if (w > h && w > 8 * g_rem) {
                                h = 8 * g_rem * h / w;
                                w = 8 * g_rem
                            } else {
                                if (h > w && h > 8 * g_rem) {
                                    w = 8 * g_rem * w / h;
                                    h = 8 * g_rem
                                }
                            }
                        }
                        canvas.width = (w + 0.4 * g_rem) * ratio;
                        canvas.height = (h + 0.4 * g_rem) * ratio;
                        canvas.style.width = w + 0.4 * g_rem + "px";
                        canvas.style.height = h + 0.4 * g_rem + "px";
                        if (h === w) {
                            ctx.beginPath();
                            ctx.arc(canvas.width / 2, canvas.height / 2, canvas.width / 2, 0, 2 * Math.PI);
                            ctx.clip()
                        }
                        ctx.strokeStyle = "#69c5ff";
                        ctx.lineWidth = 8 * g_rem * ratio;
                        loadPallet = function(tmp) {
                            ctx.beginPath();
                            ctx.arc(canvas.width / 2, canvas.height / 2, 4 * g_rem * ratio, bottomPageInfoDeg, bottomPageInfoDeg + tmp * (2 * Math.PI / 100));
                            ctx.stroke();
                            drawImg()
                        };
                        loadimg(imgPaths)
                    };
                    if (logoImg.complete) {
                        initLogoImg()
                    } else {
                        logoImg.onload = initLogoImg
                    }
                }

                function setPercent(percent) {
                    $loadPercent.innerHTML = percent;
                    if (percent === 100) {
                        var index = 0;
                        setTimeout(function() {
                            index++;
                            if (index < 10) {
                                loadPallet && loadPallet(120);
                                setTimeout(arguments.callee, 17)
                            } else {
                                loadPallet = null
                            }
                        }, 17)
                    }
                    loadPallet && loadPallet(percent)
                }

                function loading() {
                    if (numLoaded < imgPaths.length) {
                        if (percent < 100 - imgPaths.length + numLoaded) {
                            percent++;
                            setPercent(percent - 1)
                        }
                    } else {
                        percent += 10;
                        percent > 100 && (percent = 100);
                        setPercent(percent - 1)
                    } if (percent >= 100 && typeof $ != 'undefined') {
                        loadEnd()
                        return
                    }
                    setTimeout(arguments.callee, 10)
                }

                function loadEnd() {
                    setPercent(100);
                    var flag = $(window).height() / $(window).width() < 1.575;
                    var bgHeight = flag ? $(window).width() * 1.575 : $(window).height();
                    setTimeout(function() {
                        !HdGame.nootNeedFixHeight && $("#homeBgBox,.gameBgBox").css("height", bgHeight / g_rem + "rem");
                        var theObject = $(".home .bottomSkill,#bottomSkill");
                        flag && theObject.css("top", (bgHeight - $(".bottomSkill").outerHeight()) / g_rem + "rem");
                        setTimeout(function() {
                            $loadPercent = null;
                            $("#preloadPage").hide()
                        }, 500);
                        complete();
                        self.loadComplete = true;
                        for (var n = loadCallBack.length, i = 0; i < n; i++) {
                            loadCallBack[i]()
                        }
                        loadCallBack = null;
                        logoImg = null;
                        $loadPercent = null;
                        $("#preloadPage").addClass("leftClose")
                    }, 300)
                }

                function loadimg(arr) {
                    loading();
                    for (var i = arr.length - 1; i >= 0; i--) {
                        var img = new Image();
                        img.onload = loadCheckComplete;
                        img.onerror = loadCheckComplete;
                        img.src = arr[i];
                        self[arr[i]] = img
                    }
                    if (self.loadTimeout) {
                        self._loadTimer = setTimeout(loadTimeout, self.loadTimeout)
                    }
                }

                function loadTimeout() {}

                function loadCheckComplete() {
                    numLoaded++;
                    this.assets_complete = true;
                    if (numLoaded === imgPaths.length) {
                        complete()
                    }
                }

                function complete() {
                    if (self.complete) return;
                    clearTimeout(self._loadTimer);
                    numLoaded = imgPaths.length;
                    self.complete = true;
                    for (var n = readyCallBack.length, i = 0; i < n; i++) {
                        readyCallBack[i]()
                    }
                    readyCallBack = null
                }
            }
        }
    })(hg);

    hg.edit = null;
    hg.edit = {};



</script>

<script type="text/javascript">


function GetQueryString(name)
{
   var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
   var r = window.location.search.substr(1).match(reg);
   if(r!=null)return  unescape(r[2]); return null;
}

var g_config = {};

var trrId = null;
var g_awardIndex = null;
var g_giftStyle = null;
var g_activityCode = GetQueryString('code');
var initHG = function(resp){
  var rewards = resp.rewards;

  rewards = _.map(rewards, function(o){
    return _.merge(o, {
      hit_rate: o.hit_rate * 10000
    })
  })

  var sum_value = 10000;//_.sumBy(rewards, 'hit_rate');
  var random_value = _.random(1, sum_value);
  g_awardIndex = 0;
  do {
    random_value -= rewards[g_awardIndex].hit_rate;
    g_awardIndex ++;
  } while (random_value > 0 && g_awardIndex < rewards.length)
  if(g_awardIndex >= rewards.length){
    g_awardIndex = 0;

  }else{
    trrId = rewards[g_awardIndex-1].trr_id;
    g_giftStyle = rewards[g_awardIndex-1].reward_name;
  }

(function(hg){
    var origin = [
      {"name":"startBtnImg","path":[["/static/zp/ACgIABAEGAAgyIu8zwUo3JPwigMwhgE4hgE.png"],["/static/zp/ACgIABAEGAAgy4u8zwUogKSG9AEwhgE4hgE.png"]]},
      {"name":"showGifBoxer","pos":{"left":"1.4rem","top":"8rem"},"path":["/static/zp/ACgIABAEGAAg0Iu8zwUo9MzdpwYwlgQ4lgQ.png"]},
      {"name":"flashLight","path":["/static/zp/ACgIABAEGAAg34u8zwUotNbH_QcwHDgc.png"]},
      {"name":"darkLight","path":["/static/zp/ACgIABAEGAAg4ou8zwUo2Kyn6AEwHDgc.png"]},
      {"name":"priceD","path":["/static/zp/ACgIABAEGAAg6Iu8zwUo8_fMgAcwhgE4hgE.png"]},

      {"name":"thePrice1","path":[rewards.length >= 1 ? rewards[0].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice2","path":[rewards.length >= 2 ? rewards[1].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice3","path":[rewards.length >= 3 ? rewards[2].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice4","path":[rewards.length >= 4 ? rewards[3].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice5","path":[rewards.length >= 5 ? rewards[4].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice6","path":[rewards.length >= 6 ? rewards[5].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice7","path":[rewards.length >= 7 ? rewards[6].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},
      {"name":"thePrice8","path":[rewards.length >= 8 ? rewards[7].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png']},

      {"name":"thePrice900","path":["/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png"]},
      {"name":"thePrice0","path":["/static/zp/ACgIABAEGAAgnoy8zwUo1JrA4wIwhgE4hgE.png"]},
      {"name":"theGetPricePic","pos":{"left":"0.75rem","top":"0.15rem"},"size":{"width":"14.5rem","height":"18rem"},"path":[["/static/zp/faiImg.png"]]},
      {"name":"theGetPricePicTwo","pos":{"left":"0rem","top":"0rem"},"size":{"width":"4rem","height":"4rem"},"path":[["/static/zp/faiImg2.png"]]},
      {"name":"theGetPricePicThree","pos":{"left":"0rem","top":"0rem"},"size":{"width":"4rem","height":"4rem"},"path":[["/static/zp/faiImg3.png"]]},
      {"name":"lotsPot","pos":{"left":"4.9rem","top":"3rem"},"size":{"width":"6.15rem","height":"12.4rem"},"path":[["/static/zp/lots1.png"]]},
      {"name":"lotsShakeHand","pos":{"left":"4.5rem","top":"17.9rem"}},
      {"name":"advertising","path":["/static/zp/gg.jpg"]}];
    var originDef = [
      {"name":"startBtnImg","path":[["*_resRoot*/image/hlcbt/startBtn.png","抽奖按钮","5000k"],["*_resRoot*/image/hlcbt/startBtnhover.png","点击效果","5000k"]],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"showGifBoxer","pos":{"left":"1.35rem","top":"8rem"},"path":["*_resRoot*/image/hlcbt/awardD.png","九宫格图片","5000k"],"rsize":{"width":"13.35rem","height":"13.35rem"},"edit":"all"},
      {"name":"flashLight","path":["*_resRoot*/image/hlcbt/brightFlash.png","灯泡图片一","5000k","28px*28px"],"rsize":{"width":"0.7rem","height":"0.7rem"}},
      {"name":"darkLight","path":["*_resRoot*/image/hlcbt/darkFlash.png","灯泡图片二","5000k","28px*28px"],"rsize":{"width":"0.7rem","height":"0.7rem"}},
      {"name":"priceD","path":["*_resRoot*/image/hlcbt/priceD.png","奖品背景","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice1","path":["","奖项一","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice2","path":["","奖项二","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice3","path":["","奖项三","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice4","path":["","奖项四","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice5","path":["","奖项五","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice6","path":["","奖项六","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice7","path":["","奖项七","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice8","path":["","奖项八","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice900","path":["*_resRoot*/image/hlcbt/price900.png","安慰奖","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"thePrice0","path":["*_resRoot*/image/hlcbt/price0.png","谢谢参与","5000k"],"rsize":{"width":"3.35rem","height":"3.35rem"}},
      {"name":"theGetPricePic","pos":{"left":"2.1rem","top":"1.3rem"},"size":{"width":"11.5rem","height":"11.2rem"},"path":[["*_resRoot*/image/faiImg1-2.png","图片01","5000k"]],"edit":"theGetPricePic","formDefaultStyle":true},
      {"name":"theGetPricePicTwo","pos":{"left":"2.1rem","top":"1.3rem"},"size":{"width":"11.5rem","height":"11.2rem"},"path":[["*_resRoot*/image/faiImg2-2.png","图片01","5000k"]],"edit":"theGetPricePicTwo","formDefaultStyle":true},
      {"name":"theGetPricePicThree","pos":{"left":"2.1rem","top":"1.3rem"},"size":{"width":"11.5rem","height":"11.2rem"},"path":[["*_resRoot*/image/faiImg3-2.png","图片01","5000k"]],"edit":"theGetPricePicThree","formDefaultStyle":true},
      {"name":"lotsPot","pos":{"left":"4.925rem","top":"3rem"},"size":{"width":"6.15rem","height":"12.4rem"},"path":[["*_resRoot*/image/lots1.png","图片01","5000k"]],"edit":"lotsPot","formDefaultStyle":true},
      {"name":"lotsShakeHand","pos":{"left":"4.5rem","top":"17.9rem","forParent":"false"},"formDefaultStyle":true},
      {"name":"advertising","rsize":{"width":"16rem","height":"40rem"},"path":["*_resRoot*/image/gg.jpg"],"edit":"_background","formDefaultStyle":true}
    ];

    hg.edit.origin = origin;
    hg.edit.originDef = originDef;
})(hg);

//全局变量
g_config = {
  "isOpenAreaLimit":false,"isCheckPlayTimes":true,"showMenu":true,"buy":false,"isNewGame":false,"isOem":false,"scoreType":false,"showLogo":false,"flag":10390,"flagB":2304,"countsTimeType":-1,"sortType":-1,
  "drawLimitDef":0,"style":57,"gameId":344,"openId":"tryPlay_15801086","playerId":623160,
  "userName":"tp_15801086","headImg":"/static/zp/manImg.jpg","authVer":2,
  "scoreUnit":"分","testCMD":"","ajaxUrl":"","startTime":"2017-10-24 17:18","$startTime":1508836680000,"$endTime":1509441480000,
  "awardList":[
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"一等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 1 ? rewards[0].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"","onlinect":1,"continfo":3,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值100元礼品","level":1,"passwordrednum":100,"payment":1,"storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"二等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 2 ? rewards[1].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"","onlinect":1,"continfo":3,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值50元礼品","level":2,"passwordrednum":100,"payment":1,"storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"三等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 3 ? rewards[2].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"","onlinect":1,"continfo":3,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值10元礼品","level":3,"passwordrednum":100,"payment":1,"storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"四等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 4 ? rewards[3].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"","onlinect":1,"continfo":3,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值5元小礼品","level":4,"passwordrednum":100,"payment":1,"wxcardid":"","storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"五等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 5 ? rewards[4].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"","onlinect":1,"continfo":3,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值5元小礼品","level":5,"passwordrednum":100,"payment":1,"wxcardid":"","storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"六等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 6 ? rewards[5].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"/static/zp/qrcodeImg.jpg","onlinect":1,"continfo":0,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值5元小礼品","level":6,"passwordrednum":100,"payment":1,"wxcardid":"","storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"七等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 7 ? rewards[6].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"/static/zp/qrcodeImg.jpg","onlinect":1,"continfo":0,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值5元小礼品","level":7,"passwordrednum":100,"payment":1,"wxcardid":"","storeType":1},
    {"amount":0,"awardtype":2,"cashtype":2,"attention":1,"cashsite":"请填写您的兑奖地址或者门店地址","pot":0,
      "style":"八等奖","cbt":1508774400000,"cet":1509465599000,
      "cft":30,"cfbt":0,"oct":false,"oplink":false,"genewxcard":false,"iscuscode":false,"iscancelver":false,
      "stl":"","btn":"了解更多","btl":"","servicepho":"","cashinfo":"",
      "aimg":rewards.length >= 8 ? rewards[7].reward_picture : '/static/zp/ACgIABAEGAAgmYy8zwUo0uyq-QYwhgE4hgE.png',"aimgw":"6rem","aimgh":"6rem","attentionimg":"/static/zp/qrcodeImg.jpg","onlinect":1,"continfo":0,
      "excelName":"","hbtype":0,"hbAverage":1000,"floatBegin":500,"floatEnd":1500,"name":"价值5元小礼品","level":8,"passwordrednum":100,"payment":1,"wxcardid":"","storeType":1}
  ],
  "comfort":{
    "comLimitNum":false,"ccc":"","comNum":0,"cc":"","amount":0,"comModNum":0,"comoptx":false,"cas":"安慰奖","comtxc":"联系商家出示兑奖码","ca":"价值5元小礼品","comimgw":"6rem","comcashinfo":"","combtl":"","comfbt":0,
    "combtn":"了解更多","comiscuscode":false,"comimgh":"6rem","cttype":"DATE_TYPE_FIX_TIME_RANGE","comattention":1,"comiscancelver":false,"comimg":"/static/zp/gift.png","comcbt":1508774400000,
    "comcontinfo":3,"comservicephone":"","comcet":1509465599000,"conlinect":1,"ctlmt":"[8]","comattentionimg":"","comOpqrc":true,"comcashsite":"请填写您的兑奖地址或者门店地址","comAwardtype":2,"comcashtype":2,
    "comopti":"凭券联系现场工作人员兑奖","comtxn":"兑奖须知","comft":30,"comoci":false,"comoct":false,"comstl":"","comOplink":false,"comStoreType":1
  },
  "awardInfoB":"",

  "awardUsername":"","awardPhone":"","awardAddress":"","addressNum":"","status":0,
  "haveAward":true,
  "shareDeep":0,"isFromZhuliShare":false,
  "awardNum":5,"theDefaultGiftImgSrc":"/static/zp/gift.png",
  "clickTips":{"clickSrc":"/static/zp/clickView.png","pointW":"2rem","pointH":"2rem","clickW":"3.3rem","clickH":"3.65rem"},
};

HdGame.gameDomain = 'hd.faisco.cn';
HdGame.gameDomainIgnoreStyle = 'hd.faisco.cn';
HdGame.isReg = false;
HdGame.initCallBack(hg,['startGame','beforeStartGame','startGamehead','home','again','jsFootEnd','showResult','changeBottomBar','showPoup','hidePoup','timeChange','updateRankList','afterDraw','editBackground']); //hdgame
hg.register(['setGameType','hpInit','hgLoadEnd','save','changeShow','showTabByStyle']); //hdportal
HdGame.initEdit(hg.edit);
// hg.sound = HdGame.initSound([{"path":"/static/zp/bgmusic29H.mp3","fileName":"背景音乐.mp3","optFlag":0},{"path":"/static/zp/startDraw.mp3","fileName":"滚动音效.mp3","optFlag":2}],[{"path":"*_resRoot*/image/hlcbt/bgmusic29H.mp3","fileName":"背景音乐.mp3","optFlag":0},{"path":"*_resRoot*/image/hlcbt/startDraw.mp3","fileName":"滚动音效.mp3","optFlag":2}],null);
// hg.sound.readyPlay(0,0,'loop');

var GameArg = {
    awardNum : rewards.length,
};
var startStatus = true;
(function(g){
    // 排列的奖品的等级，顺时针排列
    var prizeDeg = [
        [1,1,0,1,1,0,1,1],
        [2,1,1,0,2,2,1,0],
        [3,1,2,0,3,1,0,2],
        [1,4,3,1,0,2,4,0],
        [1,2,0,3,4,0,1,5],
        [1,2,3,0,4,5,1,6],
        [1,2,3,2,4,5,0,6,7,1,7,7],
        [1,2,8,3,4,5,0,7,6,1,8,3],
    ];
    var morePricePos=[],lessPricePos = [];
    for(var i = 0;i < 12;i++){
        var a = {};
        var left,top;
        if(i < 4){
            top = 0.45;
        }else if(i == 4 || i == 11){
            top = 3.1;
        }else if( i == 5 || i == 10){
            top = 5.85;
        }else{
            top = 8.6;
        }
        if( i == 0 || i == 11 || i == 10 || i == 9){
            left = 0.3;
        }else if( i == 1 || i == 8){
            left = 3.05;
        }else if( i == 2 || i == 7){
            left = 5.8;
        }else{
            left = 8.55;
        }
        a.left = left;
        a.top = top;
        morePricePos.push(a);
    }
    for(var i = 0 ; i < 8; i++){
        var a = {};
        var left,top;
        if(i < 3){
            top = 0.45;
        }else if(i == 3 || i == 7){
            top = 4;
        }else{
            top = 7.7;
        }
        if( i == 0 || i == 6 || i == 7){
           left = 0.3;
        }else if( i == 1 || i == 5){
            left = 3.95;
        }else{
            left = 7.6;
        }
        a.left = left;
        a.top = top;
        lessPricePos.push(a);
    }
    var steps = [];
    steps.now = 0;
    var zhuanpanArg = null;//结果弹出层参数

    // 画一个圆角矩形
    function drawThePrice(theObject,flag){
        if(typeof theObject === "undefined" || (typeof theObject.left === "undefined" && !flag)){
            return;
        }
        var r = 0.2*g_rem,                                    //圆角半径
            x = theObject.left * g_rem,                       //目标矩形的左边距离
            y = theObject.top  * g_rem,                       //目标矩形的右边距离
            w = g.awardNum > 6 ? 2.45 * g_rem : 3.35 * g_rem, //目标矩形的宽
            h = w,                                            //目标句型的高
            fillStyle = "#ffffff",                            //填充颜色
            alpha = 0.0;                                      //透明度
        if(flag){
            x = 0;
            y = 0;
            r = 0.55 * g_rem;
            w = g.w;
            h = g.h;
            fillStyle = "#000000";
            alpha = 0.35;
        }
        g.ctx.save();
        g.ctx.beginPath();
        g.ctx.moveTo(x,(y + h - r));
        g.ctx.lineTo(x,( y + r));
        g.ctx.arcTo(x,y,(x + r),y,r);
        g.ctx.lineTo((x + w - r),y);
        g.ctx.arcTo((x + w),y,(w + x),(y + r),r);
        g.ctx.lineTo((w + x),(y + h - r));
        g.ctx.arcTo((w + x),(y + h),(w + x - r),(y + h),r);
        g.ctx.lineTo((x + r),(y + h));
        g.ctx.arcTo(x,(y + h),x,(y + h - r),r);
        g.ctx.clip();
        if(!flag){
            g.ctx.clearRect(0,0,g.w*g_rem,g.h*g_rem);
        }else{
            g.ctx.fillStyle = fillStyle;
            g.ctx.globalAlpha = alpha;
            g.ctx.fillRect(0,0,g.w*g_rem,g.h*g_rem);
        }
        g.ctx.restore();
    }

    // 设置奖项以及开始按钮的大小
    function setPriceAndStart(){
        $(".theShowerGiftBoxer .priceBox").html('');
        var maxSize;

        if(g.awardNum < 7){
            $(".startBtnImg").width("3.35rem").height("3.35rem").addClass("abs").css({
                "top": 4.8 * g_rem,
                "left": 4.95 * g_rem,
            });
            maxSize = 3.35*g_rem;
        }else{
            $(".startBtnImg").width("4.4rem").height("4.4rem").addClass("abs").css({
                    "top" : 4.25 * g_rem,
                    "left": ((5.2 - 4.4) / 2 + 4.05) * g_rem,
                });
            maxSize = 2.45*g_rem;
        }
        var theClassName = g.awardNum < 7 ? " biggerBoxer " : " littleBoxer ";
        var theArray = prizeDeg[ g.awardNum - 1 ];
        $.each(theArray,function(index,value){
            var theLei,theleft;
            if(g.awardNum < 7){
                if(index < 3){
                    theLei = ' top1 ';
                }else if(index == 3 || index == 7){
                    theLei = ' top2 ';
                }else{
                    theLei = ' top3 ';
                }
                if( index == 0 || index == 6 || index == 7){
                   theleft = ' left1 ';
                }else if( index == 1 || index == 5){
                    theleft = ' left2 ';
                }else{
                    theleft = ' left3 ';
                }
            }else{
                if(index < 4){
                    theLei = ' top1 ';
                }else if(index == 4 || index == 11){
                    theLei = ' top4 ';
                }else if( index == 5 || index == 10){
                    theLei = ' top5 ';
                }else{
                    theLei = ' top6 ';
                }
                if( index == 0 || index == 11 || index == 10 || index == 9){
                   theleft = ' left1 ';
                }else if( index == 1 || index == 8){
                    theleft = ' left4 ';
                }else if( index == 2 || index == 7){
                    theleft = ' left5 ';
                }else{
                    theleft = ' left6 ';
                }
            }
            var theBoxer = $('.theBoxerForEdit .editTarget-priceD').clone();
            var theSrc = hg.edit.getImgInfo('thePrice'+value).path;
            var theIndex = '<img class="editTarget-thePrice'+value+'" src="'+theSrc+'" onload="HdGame.Img.optimize(this, {width:'+maxSize+', height:'+maxSize+', mode:HdGame.Img.MODE_SCALE_DEFLATE_FILL});"/>'
            theBoxer.addClass("theImgBox abs " + theClassName+theLei+theleft).appendTo('.theShowerGiftBoxer .priceBox');
            $(".theShowerGiftBoxer .priceBox .editTarget-priceD").eq(index).append(theIndex);
        })
        var theAwardBg = hg.edit.getImgInfo("priceD").path;
        console.log(theAwardBg);
        HdGame.imgReady(theAwardBg,function(){
            var size = {width:$(".editTarget-priceD").width(),height:$(".editTarget-priceD").height()};
            var theSize = HdGame.Img.calcSize(this.width,this.height,size.width,size.height,HdGame.Img.MODE_SCALE_DEFLATE_FILL);
            $(".editTarget-priceD").css({
                "background-size" : theSize.width + "px " + theSize.height+"px"
            })
        });
    }
    function returnTheUrl(url){
        url = url.split("\"");
        return url[1];
    }
    // 生成需要转动的圈数
    function start(level) {
        var theArray = prizeDeg[g.awardNum - 1];
        var newArray = [];
        $.each(theArray,function(index,value){
            if(value == level){
               newArray.push(index);
            }
        })
        g.turningTime = getRandom(8000,12000);
        var theDecideNum = getRandomFromArray(newArray) + 1;
        g.turningZero = 6 * theArray.length + theDecideNum;  //要转的圈数
        g.nowGoingStep = 6 * theArray.length + theDecideNum; //目前的步数
        g.turningAngl = g.turningTime / g.turningZero;       //平均步数
        g.turnIngArray = [];
        for(var i = 0 ; i < 3 ; i++){
            g.turnIngArray = g.turnIngArray.concat(g.sliceArray);
        }
        for(var j = 0; j <= theDecideNum ; j++){
            g.turnIngArray.push(g.sliceArray[j]);
        }
        g.nnn = 0;
        startAnimation();
    }

  function startAnimation(){
    if(g.nowGoingStep > 0){
        var theTime = easeInOut((g.turningZero - g.nowGoingStep),0,g.turningTime,g.turningZero);
        g.nowGoingStep -= 1;
        theTime -= g.nnn;
        g.nnn += theTime;
        var theObject = g.turnIngArray[0];
        g.turnIngArray.shift();
        if(g.turnIngArray.length != 0){
            g.ctx.clearRect(0,0,g.w*g_rem,g.h*g_rem);
            drawThePrice({},true);
            drawThePrice(theObject);
            // hg.sound.play(1);
        }else{
           g.nowGoingStep = 0;
        }
        setTimeout(arguments.callee,theTime);
    }else{
        // hg.sound.play(1);
        setTimeout(function(){
            HdGame.resulePoup.show(zhuanpanArg);
        },1000);
    }
  }
  // 缓动函数
  /*
      t : 初始记步数
      b : 开始位置
      c : x轴的变化量,固定的
      d : x轴的长度
  */
  function easeInOut(t,b,c,d){
    if ((t/=d/2) < 1) return c/2*t*t + b;
    return -c/2 * ((--t)*(t-2) - 1) + b;
  }
  function getRandomFromArray(arr){
    if(HdGame.getType(arr) !== "array"){
        return -1;
    }
    var a = getRandom(0,(arr.length - 1));
    return arr[a];
  }

  function getRandom(a,b){
    if(typeof a === "undefined" ) a = 0;
    if(typeof b === "undefined" ) b = 10;
    if(a == b) return a;
    return a+Math.floor(Math.random()*(b-a+1));
  }

  function draw(){
    // 拿到数据之后，先显示动画再显示结果
    if(!startStatus) return;
    startStatus = false;
    // $(".startBtnImg").attr("src",hg.edit.getImgInfo("startBtnImg").path[1]);
    decideImg(".startBtnImg",hg.edit.getImgInfo("startBtnImg").path[1]);
    setTimeout(function(){
        // $(".startBtnImg").attr("src",hg.edit.getImgInfo("startBtnImg").path[0]);
        decideImg(".startBtnImg",hg.edit.getImgInfo("startBtnImg").path[0]);
       luckDraw(function(arg,result){
            zhuanpanArg = arg;
            $("#outer").show();
            if(arg.isSuc){
                start(result.awardIndex);
            }else{
                start(0);
            }
        });
    },200)
  }
  function decideImg(obj,url){
    (function(theObj,theUrl){
      HdGame.imgReady(theUrl,function(){
        if(typeof theObj === "string"){
            theObj = $(theObj);
        }
        var originSize = {width:theObj.outerWidth(),height:theObj.outerHeight()};
        var nowSize = HdGame.Img.calcSize(this.width,this.height,originSize.width,originSize.height,HdGame.Img.MODE_SCALE_DEFLATE_FILL);
        theObj.css({
            'background-image':'url("'+theUrl+'")',
            "background-position":"center center",
            "background-repeat":"no-repeat",
            "background-size":nowSize.width+"px "+nowSize.height+"px"
        })
      })
    })(obj,url)
  }
  function getRandomNum(a,b){
    return a+Math.floor(Math.random()*(b-a+1));
  }

  function setFlashLight() {
    $.each($(".theRealFlashLight"),function(index,value){
        if(index < 6){
            $(this).css({
                top : "-0.05rem",
                left : (0.65 + 1.9*index)*g_rem
            });
        }else if( index < 12 ){
            var theleft = (index == 6 ? 12.05*g_rem : 12.3*g_rem);
            var theTop = (index == 6 ? 0.05*g_rem : (0.2 + 1.9*(index - 6))*g_rem );
            $(this).css({
                left : theleft,
                top : theTop
            });
        }else if( index < 18 ){
            var theTop = (index == 12 ? 11.75*g_rem : 11.9*g_rem)
            $(this).css({
                top : theTop,
                left : (0.65 + 1.9*(18 - index))*g_rem
            });
        }else{
            var theleft = (index == 18 ? 0.45*g_rem : 0.35*g_rem);
            var theTop = (index == 18 ? 11.7*g_rem : (11.9 + 2*(18 - index))*g_rem );
            $(this).css({
                left : theleft,
                top : theTop
            });
        }
        if(index == ($(".theRealFlashLight").length - 1)){
            startFlash();
        }
    })
  }
  var theFlashSrc = hg.edit.getImgInfo('flashLight').path;
  var theDarkSrc = hg.edit.getImgInfo('darkLight').path;
  var theSrcArray = [];
  theSrcArray.push(theFlashSrc);
  theSrcArray.push(theDarkSrc);
  var arraySize = new Array(2);
  $.each(theSrcArray,function(index,value){
      (function(index,value){
          HdGame.imgReady(value,function(){
              var originSize = {width:$(".theRealFlashLight").outerWidth(),height:$(".theRealFlashLight").outerHeight()};
              var nowSize = HdGame.Img.calcSize(this.width,this.height,originSize.width,originSize.height,HdGame.Img.MODE_SCALE_DEFLATE_FILL);
              var pL = 100 * nowSize.width / originSize.width;
              var pt = 100 * nowSize.height / originSize.height;
              arraySize[index] = {
                  "background-image" : 'url("'+value+'")',
                  "background-size"  : pL+"% "+pt+"%",
              };
              if(index == 1){
                  setFlashLight();
              }
          })
      })(index,value);
  })
  function startFlash(){
    $.each($(".theRealFlashLight"),function(index,value){
      var theSrc = arraySize[1];
      var otherSrc = arraySize[0];
      var theFlag = $(this).hasClass("editTarget-darkLight");
      if(theFlag){
        theSrc = arraySize[0];
        otherSrc = arraySize[1];
      }
      // A亮
      if(!g.num){
        $(this).css(theSrc);
      }else{
      // B闪
        $(this).css(otherSrc);
      }
    })
    if(!g.num){
      g.num = 1;
    }else{
      delete g.num;
    }
    setTimeout(arguments.callee,500);
  }
  $(function() {
    g.sliceArray = g.awardNum > 6 ? morePricePos : lessPricePos;
    setPriceAndStart();
    decideImg(".startBtnImg",hg.edit.getImgInfo("startBtnImg").path[0]);

    hg.assets.onload(function(){
        g.w = 11.25*g_rem;
        g.h = 11.25*g_rem;
        var canvas = $('#outer')[0];
        if(typeof canvas === 'undefined') return;
        var ratio = LF.setCanvasePixelRatio();
        //压缩画布
        canvas.width = g.w*ratio;
        canvas.height = g.h*ratio;
        canvas.style.height = g.w + 'px';
        canvas.style.width = g.h + 'px';
        g.ctx = canvas.getContext("2d");
    });
    hg.on('startGame',draw);
  });
})(GameArg);

/*----------------------------------获取ip信息-----------------------------------*/
(function(){
    var curFontSize = parseFloat($("html").css("font-size"));
    if(curFontSize != g_rem) {
        var rate = 1;
        if((curFontSize / g_rem) < 0.9 || (curFontSize / g_rem) > 1.1) {
            rate = curFontSize / g_rem;
        }
        refreshRemForSpecial(g_rem,rate);
    }
    function refreshRemForSpecial(rem,rate) {
        var newFontSize = rem / rate;
        $("html").css("font-size",newFontSize + "px");
    }
})();


var gameType = 0;


HdGame.resulePoup.init({
  regUrl    : 'hdgame_h?cmd=setPlayerReg&aid=7020498&gameId=344&openId=tryPlay_15801086&flag1=true',
  home      : typeof home !== 'undefined' ? home : null,
  again     : typeof gameRestart !== 'undefined' ? gameRestart : null,
  giftInit  : HdGame._luckDrawFunc,
});

HdGame.initJsFoot({
  "rulesortstr":"abcde",
  "hostLink":"http://","menuLink":"",
  "fromFav":"",
  "menuStyle":3,
  "soundIcon_l":"0.75rem","soundIcon_t":"1rem","awardImage":"/static/zp/gift.png",
  "titleImg_path_def":"/static/zp/title.png",
  "startImg_path_def":"/static/zp/startBtn.png",
  "awardIconImgPath_def":"/static/zp/ruleImg_special.png",
  "titleImg_w_def":"15.8rem","titleImg_h_def":"7.5rem","startBtn_w_def":"","startBtn_h_def":"","logoImg_w_def":"2rem","logoImg_h_def":"2rem",
  "awardImg_w_def":"6rem","awardImg_h_def":"6rem",
  "homeBgPath_def":"/static/zp/homeBg.jpg","gameBg2Path_def":"",
  "gameBgPath_def":"","headImg2":"","headImg3":"","headImg4":"","dangerType":0,"isZhuLi":false,
})


  hg.assets.add([
      "/static/zp/ACgIABACGAAguZ28zwUoiM-W2AUwgAU4wAw.jpg",
      "/static/zp/logo.jpg",
      "/static/zp/ruleImg.png",
      "/static/zp/success.png",
      "/static/zp/light.png",
      "/static/zp/bird.png",
      "/static/zp/musicOff.png",
      "/static/zp/musicOn.png",
      "/static/zp/auBg.jpg",
      "/static/zp/manImg.jpg",
      '/static/zp/faiImg.png',
  ]);

  hg.assets.loadPage();//开始loading页面
}


$(function(){

  $.ajax({
    url: '/api/raffle/'+g_activityCode+'/verify',
    type: 'head',
    data: { activityCode: g_activityCode, memberId: member_id },
    success: function(resp) {

      $.ajax({
        url: '/api/raffle/' + g_activityCode + '/info',
        type: 'get',
        data: {activityCode: g_activityCode, mallId: 1},
        success: initHG
      })


    },error: function(err){
      if(err.status == 403) { alert('积分不足'); location.href="/member"}
    }
  })

})



function parseRemToPx(rem){
    if(rem.indexOf('rem') === -1){
        return parseFloat(rem);
    }
    return parseFloat(rem)*g_rem;
}
function parsePxToRem(px){
    if(px.indexOf('px') === -1){
        return px;
    }
    return parseFloat(px)/g_rem + 'rem';
}




function startBtnDelay() {
  $('.titleImg').removeClass('titleDown').addClass('titleDown');
  $('#startBtnImg').removeClass('startTada');
  // hg.sound.readyPlay(0, 0, 'loop');

  setTimeout(function() {
    $('#startBtnImg').addClass('startTada');
  },
  1000);
}

function showAwardDetail4Draw(fromFav) {
  HdGame.changePoup(3, '', true);
  home('showAward', fromFav);
}


function activateSound() { //兼容ios下 WebAudio类型的对象无法自动播放，必须在点击事件中播放过一次，才允许播放
  try {
    if (HdGame.isIPhone() && hg.sound.list && hg.sound.list.length > 0 && !hg.sound._activate) {
      $.each(hg.sound.list,
      function(i, val) {
        var data = hg.sound.cache[i];
        if (i > 0 && data && data.soundType == "LWebAudio") {
          data.play();
          data.stop();
        }
      });
      hg.sound._activate = true;
    }
  } catch(e) {

  }
}


function startBtnAjax(event, data, callBack, pass) {
  var that = this;
  if (!pass) {
    // activateSound();
  }


  hg.fireWith('startGame', that, [false, event, data, showGame]);
  return rt(true);
  function rt(r) {
    callBack && callBack.call(that, r, event, data, showGame);
    return r;
  }
  function showGame() {
    $('.footerBox').hide();
    $('.home,#ruleImg').hide();
    $('.gameBox').show();
    // if (typeof hg.sound.cache[0] !== 'undefined' && typeof hg.sound.cache[0].playing !== 'undefined' && !hg.sound.cache[0].playing) {
    //   hg.sound.readyPlay(0, 0, 'loop');
    // }
  }
}


function luckDraw(fn, option, pass) {
  var arg = {
    isSuc: true,
    giftStyle: '一等奖',
    giftCode: '110',
    awardTypeNum: '',
    giftImage: '',
    awardImageW: '',
    awardImageH: '',
    awardIndex: 1,
  };

  if(!trrId){
    arg.isSuc = false;
    arg.awardIndex = g_awardIndex;
    arg.giftStyle = '谢谢参与';
    return fn(arg, arg)
  }


  var member_id = localStorage.getItem('member_id');
  arg.awardIndex = g_awardIndex;
  arg.giftStyle = g_giftStyle;
  $.ajax({
    url: '/api/raffle/'+g_activityCode+'/toRaffle',
    type: 'post',
    contentType: 'application/json',
    dataType: 'json',
    data: JSON.stringify({trrId: trrId, memberId: member_id, mallId: 1}),
    success: function(resp){
      return fn(arg, arg);
    }
  })

}
</script>
</body>
</html>
